﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Satates.CMStates;

namespace Operators.CMOperators
{
     public class Move1MissionaryLeft:iOperator
    {
         public override string ToString()
        {

            return "Move 1 Missionary Left";
        }

        public int getOperatorNumber()
        {
            return 5;
        }
        public Common.Template execute(Common.Template t)
        {
            CMState s2 = (CMState)t;
            s2.setLeftMissionaries(s2.getLeftMissionaries() + 1);
            s2.setRightMissionaries(s2.getRightMissionaries() - 1);
            s2.setBoat("left");
            return s2;
        }

        public bool available(Common.Template t)
        {
            CMState s = (CMState)t;
            if (s.getBoat().Equals("right"))
                if (s.getRightMissionaries() >= 1)
                    if ((s.getRightMissionaries() - 1 >= s.getRightCanibals()) || (s.getRightMissionaries() - 1 == 0))
                        if (s.getLeftMissionaries() + 1 >= s.getLeftCanibals())
                            return true;
            return false;
        }
        public object Clone()
        {
            return this.MemberwiseClone();
        }
    }
}
